<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('物资仓储出入记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row" id="printArea">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>

                        <li>
                            物资名称：<input name="meterialName" onclick="selectMeterialTree()" id="treeName" type="text"
                                        placeholder="请选择">

                        </li>

                        <!--<li>
                                <label class="col-sm-1 control-label" >物资名称：</label>
                                <div class="col-sm-1">
                                    <div class="input-group">
                                        <input name="meterialName" onclick="selectMeterialTree()" id="treeName" type="text" placeholder="请选择" class="form-control" required>
                                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                                    </div>
                                </div>
                        </li>-->


                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>


                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncGoodsLog:add">
                 <i class="fa fa-plus"></i> 添加
             </a>
             <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
                shiro:hasPermission="system:ncGoodsLog:edit">
                 <i class="fa fa-edit"></i> 修改
             </a>
             <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
                shiro:hasPermission="system:ncGoodsLog:remove">
                 <i class="fa fa-remove"></i> 删除
             </a>
             <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ncGoodsLog:export">
                 <i class="fa fa-download"></i> 导出
             </a>-->
        </div>

        <h3 align="center"> <span th:text="出入库记录" id="ordercode" hidden="hidden"></span> </h3>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
            <h3> <span class="fl-l" id="autograph" hidden="hidden"></span> </h3>
        </div>

        <div class="btn-group-sm" id="toolbar1" role="group">

            <a class="btn btn-warning" onclick="$.table.exportExcel()" >
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-warning" id="print-btn" orderType = "22" >
                <i class="fa fa-download"></i> 打印
            </a>
            <!--            <div></div>-->
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncGoodsLog:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncGoodsLog:remove')}]];
    var prefix = ctx + "system/ncGoodsLog";

    $(function () {
        var datass = [[${@dict.getType('material_unit')}]];
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "物资仓储出入记录",
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            toolbar: 'toolbar1',
            sortName:'createTime',
            sortOrder:'desc',
            columns: [
                /*{
                checkbox: true
            }, */{
                title: "序号",
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
                {
                    field: 'goodsLogId',
                    title: '仓储出库记录id',
                    visible: false
                },
                {
                    field: 'goodsCode',
                    title: '物资批次',
                    sortable: true
                },
                {
                    field: 'meterialName',
                    title: '物资名称',
                    sortable: true
                },
                {
                    field: 'outputAmount',
                    title: '出库数量',
                    sortable: true
                },
                {
                    field: 'stockAmout',
                    title: '库存',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value /*+ $.table.selectDictLabel(datass,row.unit)*/ ;
                        }
                    }
                },
                {
                    field: 'unit',
                    title: '单位',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return $.table.selectDictLabel(datass,row.unit) ;
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '时间',
                    sortable: true
                },
                {
                    field: 'purchaserName',
                    title: '采购人'
                },
                {
                    field: 'createByName',
                    title: '入库人'
                },
                {
                    field: 'receiverName',
                    title: '领取人'
                },

                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.goodsLogId + '\')"><i class="fa fa-edit"></i>修改</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodsLogId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //物资选择树
    function selectMeterialTree() {
        var treeId = $("#treeId").val();
        var meterialId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/meterial/selectMeterialTree/" + meterialId;
        var options = {
            title: '物资选择',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        layer.close(index);
    }
    setTitle("物资管理-出库记录",true)
</script>
</body>
</html>